﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Member.Sys.DAL;

namespace Member.Sys.BLL
{
    public class BLL_Users
    {
        public BLL_Users() { }
        public readonly DAL_Users dal = new DAL_Users();

        /// <summary>
        /// 登陆验证
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool Exists(string username, string password)
        {
            return dal.Exists(username, password);
        }
        /// <summary>
        /// 验证用户名是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool Exists(string name)
        {
            return dal.Exists(name);
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            return dal.Exists(ID);
        }

        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(Member.Sys.Model.Model_Users model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        public void Update(Member.Sys.Model.Model_Users model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="ID"></param>
        public void Delete(int ID)
        {
            dal.Delete(ID);
        }

        /// <summary>
        /// 删除数据   
        /// </summary>
        /// <param name="strWhere">如:(ID=1)or (Name=admin)</param>
        public void Delete(string strWhere)
        {
            dal.Delete(strWhere);
        }

        /// <summary>
        /// 更改用户密码  
        /// </summary>
        /// <param name="id">ID</param>
        /// <param name="password">密码</param>
        public void Update_password(int id, string password)
        {
            dal.Update_password(id, password);
        }

        /// <summary>
        /// 更新用户密码
        /// </summary>
        /// <param name="user">用户名</param>
        /// <param name="password">密码</param>
        public void Update_password(string user, string password)
        {
            dal.Update_password(user, password);
        }

        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="Status"></param>
        public void UpdateStatus(int id, int Status)
        {
            dal.UpdateStatus(id, Status);
        }

        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Status"></param>
        public void UpdateStatus(string Name, int Status)
        {
            dal.UpdateStatus(Name, Status);
        }

        /// <summary>
        /// 更新授权时间
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="EndTime"></param>
        public void UpdateEndTime(int ID, DateTime EndTime)
        {
            dal.UpdateEndTime(ID, EndTime);
        }

        /// <summary>
        /// 更新授权时间
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="EndTime"></param>
        public void UpdateEndTime(string Name, DateTime EndTime)
        {
            dal.UpdateEndTime(Name, EndTime);
        }

        /// <summary>
        /// 根据ID得到一个实体
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public Member.Sys.Model.Model_Users GetModel(int ID)
        {
            return dal.GetModel(ID);
        }

        /// <summary>
        /// 根据用户名得到一个实体
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public Member.Sys.Model.Model_Users GetModel(string Name)
        {
            return dal.GetModel(Name);
        }



    }
}
